package top.yongyan0624.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import top.yongyan0624.mapper.RoomMapper;
import top.yongyan0624.pojo.Room;
import top.yongyan0624.pojo.Room;
import top.yongyan0624.service.RoomService;

import java.util.List;

/**
 * @author Yongyan
 * @description: TODO
 * @date 2020/12/25
 **/

@Service
public class RoomServiceImpl implements RoomService {
    @Autowired
    private RoomMapper roomMapper;

    public Integer addRoom(Room room) {
        return roomMapper.addRoom(room);
    }

    public Integer deleteRoom(Integer id) {
        return roomMapper.deleteRoom(id);
    }

    public Integer updateRoom(Room room) {
        return roomMapper.updateRoom(room);
    }

    public List<Room> findAllRoom() {
        return roomMapper.findAllRoom();
    }

    public PageInfo<Room> findAllRoom(Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        List<Room> roomList = roomMapper.findAllRoom();

        return new PageInfo<Room>(roomList);
    }

    public Room findById(Integer id) {
        return roomMapper.findById(id);
    }

    public List<Room> findRoom(Room room) {
        return roomMapper.findRoom(room);
    }

    public Integer totalRoom() {
        return roomMapper.totalRoom();
    }
}
